pims provides three classes for loading video.
ImageSequence reads images from a directory.Video reads standard video files (AVI, MOV, etc.).TiffStack reads multi-frame TIF / TIFF files.Once loaded, these objects can be handled alike. In software terms, each is a subclass of a generic Frames object.
The differences between the formats are handled quietly by pims.
Take ImageSequence as an example. We have a folder of images here:
In [1]:
    
ls image_sequence
    
    
We can load them into an ImageSequence object.
In [2]:
    
import pims
    
In [6]:
    
v = pims.ImageSequence('/home/dallan/mr/mr/tests/video/image_sequence/')
    
We can see basic properties.
In [7]:
    
v
    
    Out[7]:
We can print the first frame (it's an array of brightness values) or view those values as an image.
In [8]:
    
v[0]
    
    Out[8]:
In [11]:
    
%matplotlib inline
from pylab import *
imshow(v[0], cmap=cm.gray)
    
    Out[11]:
    
Because the developer does most of his work in brightfield, 
all of the contructors (Video, ImageSequence, TiffStack) invert black and white
when they load the video. To suppress this, set invert=False.
In [12]:
    
uninverted = pims.ImageSequence('image_sequence/', invert=False)
imshow(uninverted[0], cmap=cm.gray)
    
    Out[12]:
    
In [ ]:
    
for frame in v[:]:
    # Do something with frame, a numpy array.
    
ImageSequence relies only on numpy and scipy, which are required dependencies of mr, so it works
out of the box. Video needs OpenCV, which includes the Python module cv2.
TiffStack needs libtiff.
Once these dependencies are in place, Video and TiffStack work in the same way as ImageSequence.
In [14]:
    
v = pims.Video('/home/dallan/mr/mr/tests/water/bulk-water.mov')
# This file is not included in PIMS, to keep the file size small.
# Try it with a video file of your own.
    
In [15]:
    
v
    
    Out[15]:
In [19]:
    
v = pims.TiffStack('tiff_stack.tif')
    
In [20]:
    
v
    
    Out[20]: